<template>
  <el-form :inline="false" @submit.native.prevent="handleFormSubmit">
    <el-form-item>
      <el-input
        v-model="formData.className"
        placeholder="请输入分类名称"
        clearable
      ></el-input>
    </el-form-item>
    <el-form-item class="text-center">
      <el-button @click="handleCancel">取消</el-button>
      <el-button type="primary" native-type="submit">确定</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  name: "CateFrom",

  data() {
    return {
      formData: { className: "" },
    };
  },

  methods: {
    handleCancel() {
      this.$emit("cancel");
    },

    handleFormSubmit() {
      if (!this.formData.className) return
      this.$emit('sure', this.formData)
      this.$nextTick(this.resetForm)
    },

    resetForm() {
      this.formData.className = ''
    }
  },
};
</script>

<style>
</style>